<template>
	<el-dialog title="版本对话框" v-model="visible" :width="330" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="80px" label-position="left">
			<el-form-item label="版本标题" prop="title">
				<el-input v-model="form.title" clearable placeholder="版本标题"></el-input>
			</el-form-item>
			<el-form-item label="备注说明" prop="remark">
				<el-input v-model="form.remark" clearable placeholder="备注说明" type="textarea" maxlength="100"></el-input>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	props: {
		formId: String,
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			form: {
				formId: this.formId,
				title: "",
				remark: "",
			},
			rules: {
				title: [
					{required: true, message: '版本标题不能为空'}
				]
			},
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this;
		},
		//表单提交方法
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.bpm.bpmFormVersion.setBpmFormVersion.post(this.form);
					if (res.code == 200) {
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
					this.visible = false;
				}
			})
		},
	}
}
</script>

<style>
</style>
